#ifndef TEST_GRAPHICS_TEST_RUNNER_H
#	define TEST_GRAPHICS_TEST_RUNNER_H

#include "test.h"

namespace dw {
	namespace test {

class Test;

class Runner
{
public : //! @name Construction & Destruction
	//! @{
	Runner() { ; }
	virtual ~Runner()
	{
		TestsCollection::const_iterator testsEnd = m_tests.end();

		for (TestsCollection::iterator testIt = m_tests.begin(); testIt != testsEnd; ++testIt)
		{
			delete *testIt;
		}

		m_tests.clear();
	}
	//! @}

public : //! @name Commands
	//! @{
	template< class T >
	bool add()
	{
		m_tests.push_back(new T());

		return true;
	}

	virtual bool run()
	{
		bool succeed = true;

		if (succeed)
		{
			TestsCollection::const_iterator testsEnd = m_tests.end();

			for (TestsCollection::iterator testIt = m_tests.begin(); testIt != testsEnd; ++testIt)
			{
				Test* test = *testIt;

				bool testSucceed = false;
				if (test->setup())
				{
					testSucceed = test->run();
				}

				succeed = test->teardown() && testSucceed && succeed;
			}
		}

		return succeed;
	}
	//! @}

private : //! @name Types definitions
	//! @{
	typedef std::vector< dw::test::Test* > TestsCollection;
	//! @}

private : //! @name Data
	//! @{
	TestsCollection m_tests;
	//! @}
};

	} // namespace test
} // namespace dw

#endif // !TEST_GRAPHICS_TEST_RUNNER_H
